package com.donggua.aichebao.commonui.Dialog;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.view.View;
import android.widget.TextView;
import android.widget.Button;
import com.donggua.aichebao.commonui.R;
/**
 * Created by fzh on 2017/8/18.
 */

public class DGCustomServiceDlg extends DGDialogBase implements View.OnClickListener{
    private TextView tvPhone;
    private String mPhone;
    public DGCustomServiceDlg(Context context) {
        super(context);
        setContentView(R.layout.dg_dlg_client_call_dlg);
        tvPhone = (TextView)findViewById(R.id.tv_dlgCommonClientPhone);
        Button btn = (Button)findViewById(R.id.btn_PhoneCancel);
        btn.setOnClickListener(this);
        btn = (Button)findViewById(R.id.btn_PhoneCall);
        btn.setOnClickListener(this);
    }

    public void setPhone(String phone){
        mPhone = phone;
        tvPhone.setText(phone);
    }
    @Override
    public void onClick(View view) {
        int id = view.getId();
        if(id == R.id.btn_PhoneCancel){
            closeDialog();
        }else if(id == R.id.btn_PhoneCall){
            call(mPhone);
        }
    }

    private void call(String phone) {
        Intent intent=new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+phone));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        getContext().startActivity(intent);
    }
}
